package cn.edu.sdju.fengguoyu.ahoedgemonitor;

import io.grpc.Server;
import io.grpc.ServerBuilder;

import java.io.IOException;

public class AhoEdgeMessageListener extends Thread {
    private Server server;
    @Override
    public void run() {
        System.out.println("AhoEdgeMessageListener started");

        ServerBuilder<?> serverBuilder = ServerBuilder.forPort(2339);
        serverBuilder.addService(new AhoEdgeMessageService());
        server = serverBuilder.build();
        try {
            server.start();
            System.out.println("listening");
            server.awaitTermination();
            System.out.println("Quit");
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            System.out.println("IO error");
            throw new RuntimeException(e);
        }

    }
}
